﻿namespace Web.Control.Member.Public
{
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;    
    using System.Collections;
    using Lx.Web.Common.UI;
    using Lx.Web.Common.ControlsUI;
    using Model.WWW_User.User;

    public class SAnswers : BaseControl
    {
        /// <summary>
        /// 当前用户与该会员关系1好友，2已是联系人，0无int、
        /// </summary>
        protected int UserRelation = -1;
        /// <summary>
        /// 查看会员信息
        /// </summary>
        protected UserProfileModel userInfo;        
        /// <summary>
        /// 当前用户编号
        /// </summary>
        protected string mymemberno = "";
        //回答问题
        protected Repeater rptQA;
        /// <summary>
        /// 回答数量
        /// </summary>
        protected int RecordCount;
        protected int PageIndex = 1;        
        protected Literal litCount;
        protected int PageSize = 15;

        protected override void OnLoad(EventArgs e)
        {
            mymemberno = HttpContext.Current.User.Identity.Name;
            if (string.IsNullOrEmpty(Request["MNo"]))
            {
                Response.End();
                return;
            }
            string memberno = Request["MNo"];
            if (!string.IsNullOrEmpty(Request["p"]))
            {
                if (Request["p"] == "L")
                {
                    PageIndex = 999;
                }
                else
                {
                    int.TryParse(Request["p"], out PageIndex);
                    if (PageIndex == 0)
                    {
                        PageIndex = 1;
                    }
                }
            }
            if (litCount != null) int.TryParse(litCount.Text, out PageSize);
            ArrayList arrList = BLF.WWW_User.Users.User.GetUserPAnswerQs(memberno, mymemberno, PageIndex, PageSize);
            if (arrList != null)
            {
                UserRelation = (int)arrList[0];
                userInfo = arrList[1] as UserProfileModel;
                if (rptQA != null)
                {
                    rptQA.DataSource = arrList[2];
                    rptQA.DataBind();
                }
                RecordCount = (int)arrList[3];
                //title
                this.DynamicTitle = GetText("{0}'s answers - italki", new string[] { userInfo.Nickname });
                this.DynamicKeywords = GetText("{0}, answers", new string[] { userInfo.Nickname });
                this.DynamicDescription = GetText("{0}'s answers at italki", new string[] { userInfo.Nickname });
            }
            else
            {
                Response.End();
                return;
            }
        }
    }
}

